CDIR =../../../..
INCDIR=$(CDIR)/include
CHARMC=$(CDIR)/bin/charmc $(OPTS)

LIB = libmodulecompletion.a
LIBOBJ = completion.o

HEADERS = $(INCDIR)/completion.decl.h \
          $(INCDIR)/completion.def.h \
          $(INCDIR)/completion.h
LIBDEST =  $(CDIR)/lib/$(LIB)

CIFILES = completion.ci

all: $(LIBDEST) $(HEADERS)

$(INCDIR)/completion.decl.h: completion.decl.h
	/bin/cp completion.decl.h $(CDIR)/include
$(INCDIR)/completion.def.h: completion.def.h
	/bin/cp completion.def.h $(CDIR)/include
$(INCDIR)/completion.h: completion.h
	/bin/cp completion.h $(CDIR)/include

$(LIBDEST): $(LIBOBJ)
	$(CHARMC) -o $(LIBDEST) $(LIBOBJ) 

completion.def.h: completion.decl.h

completion.decl.h : completion.ci $(CDIR)/bin/charmxi
	$(CHARMC) -c completion.ci

clean:
	rm -f conv-host *.o *.decl.h *.def.h core  $(LIB)

include Make.depends

DEPENDFILE = Make.depends

depends:  completion.decl.h
	echo "Creating " $(DEPENDFILE) " ..."; 	\
	if [ -f $(DEPENDFILE) ]; then \
           /bin/cp -f $(DEPENDFILE) $(DEPENDFILE).old; \
        fi; \
	echo '#generated by make depends' > $(DEPENDFILE); \
        for i in $(LIBOBJ) ; do \
	      SRCFILE=`basename $$i .o`.C ; \
              echo "checking dependencies for $$i : $$SRCFILE" ; \
              g++ -MM -Wno-deprecated -I$(CDIR)/tmp $$SRCFILE >> $(DEPENDFILE); \
              echo '	$$(CHARMC) -I$(CDIR)/tmp -o '$$i $$SRCFILE >> $(DEPENDFILE) ; \
        done; 

